<?php

namespace App\Http\Resources;

use Illuminate\Http\Resources\Json\JsonResource;

class HomeResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param \Illuminate\Http\Request $request
     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
     */
    public function toArray($request)
    {
        return parent::toArray($request);
    }

    public static function success($request, $message = '成功', $code = 'SUCCESS')
    {
        $resource['message'] = $message;
        $resource['code'] = $code;
        return parent::make($request)->additional($resource);
    }

    public static function fail($request, $message = '失败', $code = 'FAIL')
    {
        $resource['message'] = $message;
        $resource['code'] = $code;
        return parent::make($request)->additional($resource);

    }

}
